#include <bits/stdc++.h>

using namespace std;

const int maxn=505;

double g[maxn][maxn],a[maxn][maxn],b[maxn];

inline void printArray(double (*a)[maxn],const int &n){  //For Debug
    for(int i=1;i<=n;i++,putchar('\n'))
        for(int j=1;j<=n;j++)
            printf("%.4f ",a[i][j]);
}

inline void GaussElimination(const int &n){
    for(int i=1;i<=n;i++){
        int tar=i;
        for(int j=i+1;j<=n;j++) if(fabs(a[j][i])>fabs(a[tar][i])) tar=j;
        for(int j=i;j<=n;j++) swap(a[tar][j],a[i][j]);swap(b[tar],b[i]);

        for(int j=i+1;j<=n;j++){
            double rate=a[j][i]/a[i][i];
            for(int k=i;k<=n;k++) a[j][k]-=rate*a[i][k];
            b[j]-=rate*b[i];
        }
    }
    //printArray(a,n);

    for(int i=n;i>=1;i--){
        for(int j=i+1;j<=n;j++) b[i]-=a[i][j]*b[j],a[i][j]=0;
        b[i]/=a[i][i];a[i][i]=1;
    }
}

inline int read(){
    char c;int r;bool f=0;
    for(c=getchar();c>'9'||c<'0';c=getchar()) if(c=='-') f=1;
    for(r=0;c<='9'&&c>='0';c=getchar()) r=r*10+c-'0';
    if(f) return -r;
    else return r;
}

int main(){
    int n,m;

    while(~scanf("%d%d",&n,&m)){
        memset(b,0,sizeof b);memset(a,0,sizeof a);memset(g,0,sizeof g);
        while(m--){
            int x,y,r;
            x=read();y=read();r=read();
            g[x][y]+=1.0/r;g[y][x]+=1.0/r;
        }
        for(int i=1;i<=n;i++)
            for(int j=1;j<=n;j++)
                a[i][i]+=g[i][j],a[i][j]-=g[i][j];
        b[1]=1;b[n]=-1;
        a[n][n]++;
        //printArray(a,n);
        GaussElimination(n);
        printf("%.2f\n",b[1]);
    }
    return 0;
}
